<<<<<<< HEAD
<?php
/**
 * 发布管理
 * @author Administrator
 *
 */
class Leaveword extends MY_Controller {
	/**
	 * 登陆验证
	 */
	function __construct(){
			parent::__construct();
			$user = $this->session->userdata('rsh_user');
			if(!isset($user['user_id'])){
				$str = $_SERVER['REQUEST_URI'];
				$this->js->go('/login.html');
			}elseif(!$user['user_id']){
				$this->js->go('/login.html');
			}
		}
		
	   public function logout(){
				$this->session->set_userdata('rsh_user','');
				$this->js->go('/login/index/index.html');
	   }
			   
	   
	   /**
	    * 发布留言
	    */
	   public function release(){
			$act = $this->input->post('act');
			$user = $this->session->userdata('rsh_user');
			$user_id = $user['user_id'];
			
			if($act == 'submit'){
				$ret = array('msg'=>'','url'=>'');
				$title = $this->input->post('title');
				if ($title =="" ){
					$ret['msg'] = '标题不能为空';
					echo json_encode($ret);
					exit;
				}
				
				$contents = $this->input->post('contents');
				if ($contents == "" ){
					$ret['msg'] = '内容不能为空';
					echo json_encode($ret);
					exit;
				}
				
				$data = array(
					'ftime'  	=> time(),
				    'ip' 		=> $_SERVER["REMOTE_ADDR"],
					'user_id'	=> $user['user_id'],
					'title' 	=> trim($this->input->post("title")),
					'content'   => trim($this->input->post("contents")),
				);
				$this->load->model('Leaveword_model','leaveword');
				$this->leaveword->add($data);
				echo json_encode($ret);exit;
			}
			
			$data = $this->get_user_info('','leaveword','invite');
			
			$this->load->view('leaveword/leaveword_release',$data);
	   }
	   
	   /**
	    * 前台留言列表 
	    */
	   public function leaveword_list(){
	   		$this->load->model('Leaveword_model','leaveword');
	   		$user = $this->session->userdata('rsh_user');
			$user_id = $user['user_id'];
			$per_page 		= intval($this->input->get('per_page')?$this->input->get('per_page'):0);
			$data = array();
			$data['where']['user_id'] = $user_id;
			$data['page_size']= LEAVEWORD_LIST_PAGE_SIZE; 
			$data['per_page'] = $per_page;
			$data['select']   = 1;
			
			$vdata = $this->get_user_info('','leaveword','invite');
			
			$leaveword = $this->leaveword->leaveword_list($data);
			$vdata['leaveword_list'] = $leaveword['leaveword_list'];
			//分页
			$this->load->library('pagination');
			$config['base_url'] = "/leaveword/leaveword_list/index.html?";
			$config['total_rows'] = $vdata['leaveword_count'];
			$config['per_page'] = LEAVEWORD_LIST_PAGE_SIZE; 
			$this->pagination->initialize($config); 
			$this->load->view('leaveword/leaveword_list',$vdata);
	   }
	   
	   /**
	    * 显示留言详细信息
	    */
	   public function leaveword_all_list($id){
   			$this->load->model('Leaveword_model','leaveword');
   			$data = array();
	  		$data['info'] = $this->leaveword->leaveword_all_list($id);
	  		$this->load->view("/leaveword/leaveword_all_list", $data);
	   }
}

=======
<?php
/**
 * 发布管理
 * @author Administrator
 *
 */
class Leaveword extends MY_Controller {
    /**
	 * 登陆验证
	 */
	function __construct(){
			parent::__construct();
			$user = $this->session->userdata('rsh_user');
			if(!isset($user['user_id'])){
				$str = $_SERVER['REQUEST_URI'];
				$this->js->go('/login.html');
			}elseif(!$user['user_id']){
				$this->js->go('/login.html');
			}
		}
		
	   public function logout(){
				$this->session->set_userdata('rsh_user','');
				$this->js->go('/login/index/index.html');
	   }
			   
	   
	   /**
	    * 发布留言
	    */
	   public function release(){
			$act = $this->input->post('act');
			$user = $this->session->userdata('rsh_user');
			$user_id = $user['user_id'];
			
			if($act == 'submit'){
				$ret = array('msg'=>'','url'=>'');
				$title = $this->input->post('title');
				if ($title =="" ){
					$ret['msg'] = '标题不能为空';
					echo json_encode($ret);
					exit;
				}
				
				$contents = $this->input->post('contents');
				if ($contents == "" ){
					$ret['msg'] = '内容不能为空';
					echo json_encode($ret);
					exit;
				}
				
				$data = array(
					'ftime'  	=> time(),
				    'ip' 		=> $_SERVER["REMOTE_ADDR"],
					'user_id'	=> $user['user_id'],
					'title' 	=> trim($this->input->post("title")),
					'content'   => trim($this->input->post("contents")),
				);
				$this->load->model('Leaveword_model','leaveword');
				$this->leaveword->add($data);
				echo json_encode($ret);exit;
			}
			
			$data = $this->get_user_info('','leaveword','invite');
			
			$this->load->view('leaveword/leaveword_release',$data);
	   }
	   
	   /**
	    * 前台留言列表 
	    */
	   public function leaveword_list(){
	   		$this->load->model('Leaveword_model','leaveword');
	   		$user = $this->session->userdata('rsh_user');
			$user_id = $user['user_id'];
			$per_page 		= intval($this->input->get('per_page')?$this->input->get('per_page'):0);
			$data = array();
			$data['where']['user_id'] = $user_id;
			$data['page_size']= LEAVEWORD_LIST_PAGE_SIZE; 
			$data['per_page'] = $per_page;
			$data['select']   = 1;
			
			$vdata = $this->get_user_info('','leaveword','invite');
			
			$leaveword = $this->leaveword->leaveword_list($data);
			$vdata['leaveword_list'] = $leaveword['leaveword_list'];
			//分页
			$this->load->library('pagination');
			$config['base_url'] = "/leaveword/leaveword_list/index.html?";
			$config['total_rows'] = $vdata['leaveword_count'];
			$config['per_page'] = LEAVEWORD_LIST_PAGE_SIZE; 
			$this->pagination->initialize($config); 
			$this->load->view('leaveword/leaveword_list',$vdata);
	   }
	   
	   /**
	    * 显示留言详细信息
	    */
	   public function leaveword_all_list($id){
   			$this->load->model('Leaveword_model','leaveword');
   			$data = array();
	  		$data['info'] = $this->leaveword->leaveword_all_list($id);
	  		$this->load->view("/leaveword/leaveword_all_list", $data);
	   }
}

>>>>>>> d47623b610d79a4eeb489500830c00d70933f414
?>